# 方法一：
def fun(n):
    total = 0
    for i in range(1, n + 1):
        x = 1
        for j in range(1, i + 1):
            x = x * j
        total = total + x
    print(f"1!+...+{n}!的阶乘结果是:{total}")


fun(3)


# 方法二：
def get_total(n):
    def fun2(m):
        if m == 1:
            return 1
        else:
            return m * fun2(m - 1)

    total = sum(fun2(n) for n in range(1, n + 1))
    print(f"1!+...+{n}!的阶乘结果是:{total}")


get_total(3)

# 方法三
import math


def get_total2(n):
    total = sum(math.factorial(i) for i in range(1, n + 1))
    print(f"1!+...+{n}!的阶乘结果是:{total}")


get_total2(3)
